#!/bin/sh
prev_min=`date -d -1minute +"%d/%b/%Y:%H:%M"`
access_log_path="/var/log/apache2/access.log"
grep $prev_min $access_log_path |grep 'service=NEW_ALERT' | grep -v 304|perl -e 'while(<>){ chomp; my $str = $_; $str =~ /.*?service=NEW_ALERT&email=(.*?)&area_codes=(.*?),&hours=(.*?)&days=(.*?)\ HTTP.*?200.*/; print "insert into user_prefs values(\"\",\"$1\",\"$2\",$3,\"$4\",\"\");\n";}' |mysql -ufbads -pfbads tar
